import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'animate.css';
import Cookie from 'js-cookie'
import countTo from 'vue3-count-to'
document.title = "MES";

const app = createApp(App)
app.use(countTo)
app.use(store)
app.use(router)
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// 路由守卫
router.beforeEach((to, from,next) => {

  // 判断cookie是否为容
  const token= Cookie.get('token');
  if (!token && to.name!=='登录') {
    next({name:'登录'})
  }else if(token && to.name==='登录'){
    next({name:'首页'})
  }else{
    next()
  }
})
app.mount('#app')






